package com.autonavi.notify.controller;



import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.autonavi.notify.entity.User;
import com.autonavi.notify.service.UserService;


@Controller
public class UserCtrl {
	
	protected Logger logger = LoggerFactory.getLogger(getClass());
	
	@Autowired
	UserService userService;
	
	@RequestMapping(value = "/user/page/{page}")
	@ResponseBody
	public Page<User> getUsers(@PathVariable int page){
		Page<User> result = userService.findAll(page);
		return result;
	}

	
	@RequestMapping(value = "/user/delete/{userid}")
	@ResponseBody
	public boolean getUsers(@PathVariable String userid){
		userService.delete(userid);
		return true;
	}
	
	
	@RequestMapping(value = "/user/add")
	@ResponseBody
	public boolean getUsers(@ModelAttribute User user){
		userService.save(user);
		return true;
	}
	
}
